import axios from "../utils/index";
import { getItem } from "../utils/localDate";
// 登录
export const userLoginAPI = (data) => {
  return axios({
    method: "POST",
    url: "/login",
    data,
  });
};
// 注册
export const userRegisterAPI = (data) => {
  return axios({
    method: "POST",
    url: "/register",
    data,
  });
};

// 用户详情
export const userDetailByIdAPI = (id) => {
  return axios({
    method: "get",
    url: "/user/" + id,
    // 用户详情接口需要验证，把本地存储的 token 值带上
    // headers: {
    //   // Authorization: localStorage.getItem("hmtt"),
    //   Authorization: getItem(),
    // },
  });
};

// 编辑用户信息
export const userUpdateByIdAPI = (id, data) => {
  return axios({
    method: "post",
    url: "/user_update/" + id,
    // 用户详情接口需要验证，把本地存储的 token 值带上
    // headers: {
    //   // Authorization: localStorage.getItem("hmtt"),
    //   Authorization: getItem(),
    // },
    data,
  });
};
// 关注用户
export const userFollowByIdAPI = (id) => {
  return axios({
    method: "GET",
    url: `/user_follows/${id}`,
  });
};

// 取消用户
export const userUnFollowByIdAPI = (id) => {
  return axios({
    method: "GET",
    url: `/user_unfollow/${id}`,
  });
};
// 获取关注用户列表
export const getUserFollowsAPI = () => {
  return axios({
    method: "GET",
    url: `/user_follows`,
  });
};
// 获取收藏文章列表
export const getUserStarAPI = () => {
  return axios({
    method: "GET",
    url: `/user_star`,
  });
};

// 获取评论列表
export const getUserCommentsAPI = () => {
  return axios({
    method: "GET",
    url: `/user_comments`,
  });
};
